home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / inn1.000 / inn1.4sec-linux-src.tar / inn / samples / docheckgroups < prev    next >
Text File  |  1993-03-18  |  3KB  |  122 lines

  1. #! /bin/sh
  2. ##  $Revision: 1.4 $
  3. ##  Script to execute checkgroups text; results to stdout.
  4.  
  5. ##  =()<. @<_PATH_SHELLVARS>@>()=
  6. . /news/lib/innshellvars
  7. T=${TMPDIR}
  8.  
  9. cat /dev/null >${T}/$$out
  10.  
  11. ##  Copy the article without headers, append local newsgroups.
  12. cat >${T}/$$msg
  13. test -f ${LOCALGROUPS} && cat ${LOCALGROUPS} >>${T}/$$msg
  14.  
  15. ##  Get the top-level newsgroup names from the message and turn it into
  16. ##  an egrep pattern.
  17. PATS=`${SED} <${T}/$$msg \
  18.     -e 's/[     ].*//' -e 's/\..*//' \
  19.     -e 's/^!//' -e '/^$/d' \
  20.     -e 's/^/^/' -e 's/$/[.     ]/' \
  21.     | sort -u \
  22.     | (tr '\012' '|' ; echo '' )\
  23.     | ${SED} -e 's/|$//'`
  24.  
  25. ${EGREP} "${PATS}" ${ACTIVE} | ${SED} 's/ .*//' | sort >${T}/$$active
  26. ${EGREP} "${PATS}" ${T}/$$msg | ${SED} 's/[     ].*//' | sort >${T}/$$newsgrps
  27.  
  28. comm -13 ${T}/$$active ${T}/$$newsgrps >${T}/$$missing
  29. comm -23 ${T}/$$active ${T}/$$newsgrps >${T}/$$remove
  30.  
  31. ${EGREP} "${PATS}" ${ACTIVE} | ${SED} -n '/ m$/s/ .*//p' | sort >${T}/$$amod.all
  32. ${EGREP} "${PATS}" ${T}/$$msg |
  33. ${SED} -n '/(Moderated)$/s/[     ].*//p' | sort >${T}/$$ng.mod
  34.  
  35. comm -12 ${T}/$$missing ${T}/$$ng.mod >${T}/$$add.mod
  36. comm -23 ${T}/$$missing ${T}/$$ng.mod >${T}/$$add.unmod
  37. cat ${T}/$$add.mod ${T}/$$add.unmod >>${T}/$$add
  38.  
  39. comm -23 ${T}/$$amod.all ${T}/$$remove >${T}/$$amod
  40. comm -13 ${T}/$$ng.mod ${T}/$$amod >${T}/$$ismod
  41. comm -23 ${T}/$$ng.mod ${T}/$$amod >${T}/$$nm.all
  42. comm -23 ${T}/$$nm.all ${T}/$$add >${T}/$$notmod
  43.  
  44. if [ -s ${T}/$$remove ] ; then
  45.     (
  46.     echo "# The following newsgroups are non-standard."
  47.     ${SED} "s/^/#    /" ${T}/$$remove
  48.     echo "# You can remove them by executing the commands:"
  49.     for i in `cat ${T}/$$remove` ; do
  50.         echo "    ctlinnd rmgroup $i"
  51.         ${EGREP} "^$i    " ${NEWSGROUPS} >>${T}/$$ngdel
  52.     done
  53.     echo ''
  54.     ) >>${T}/$$out
  55. fi
  56.  
  57. if [ -s ${T}/$$add ] ; then
  58.     (
  59.     echo "# The following newsgroups were missing and should be added."
  60.     ${SED} "s/^/#    /" ${T}/$$add
  61.     echo "# You can do this by executing the command(s):"
  62.     for i in `cat ${T}/$$add.unmod` ; do
  63.         echo "    ctlinnd newgroup $i y ${FROM}"
  64.         ${EGREP} "^$i    " ${T}/$$msg >>${T}/$$ngadd
  65.     done
  66.     for i in `cat ${T}/$$add.mod` ; do
  67.         echo "    ctlinnd newgroup $i m ${FROM}"
  68.         ${EGREP} "^$i    " ${T}/$$msg >>${T}/$$ngadd
  69.     done
  70.     echo ''
  71.     ) >>${T}/$$out
  72. fi
  73.  
  74. if [ -s ${T}/$$ismod ] ; then
  75.     (
  76.     echo "# The following groups are incorrectly marked as moderated:"
  77.     ${SED} "s/^/#    /" ${T}/$$ismod
  78.     echo "# You can correct this by executing the following:"
  79.     for i in `cat ${T}/$$ismod` ; do
  80.         echo "    ctlinnd changegroup $i y"
  81.         ${EGREP} "^$i    " ${T}/$$msg >>${T}/$$ngchng
  82.     done
  83.     echo ''
  84.     ) >>${T}/$$out
  85. fi
  86.  
  87. if [ -s ${T}/$$notmod ] ; then
  88.     (
  89.     echo "# The following groups are incorrectly marked as unmoderated:"
  90.     ${SED} "s/^/#    /" ${T}/$$notmod
  91.     echo "# You can correct this by executing the following:"
  92.     for i in `cat ${T}/$$notmod` ;do
  93.         echo "    ctlinnd changegroup $i m"
  94.         ${EGREP} "^$i    " ${T}/$$msg >>${T}/$$ngchng
  95.     done
  96.     echo ''
  97.     ) >>${T}/$$out
  98. fi
  99.  
  100. test -s ${T}/$$out && {
  101.     cat ${T}/$$out
  102.     echo 'exit # so you can feed this message into the shell'
  103.     echo "# And remember to update ${NEWSGROUPS}."
  104.     test -s ${T}/$$ngdel && {
  105.     echo "# Remove these lines:"
  106.     ${SED} "s/^/#    /" ${T}/$$ngdel
  107.     echo ''
  108.     }
  109.     test -s ${T}/$$ngadd && {
  110.     echo "# Add these lines:"
  111.     ${SED} "s/^/#   /" ${T}/$$ngadd
  112.     echo ''
  113.     }
  114.     test -s ${T}/$$ngchng && {
  115.     echo "# Change these lines:"
  116.     ${SED} "s/^/#   /" ${T}/$$ngchng
  117.     echo ''
  118.     }
  119. }
  120.  
  121. rm -f ${T}/$$*
  122.